import authorizeApi from 'api/authorize'

// state
let state = {
  person_info: {}
  // authorize_list: {}
}

// getters
const getters = {
  person_info: state => state.person_info
  // authorize_list: state => state.authorize_list
}

// actions
const actions = {
  person_info ({ commit, state }, params) { // 获取个人资料api
    authorizeApi.info(params).then((json) => {
      commit('PERSON_INFO', {
        params: params,
        data: json.data
      })
    }).catch((ERR) => {
      if (ERR.result === '2103') {
        commit('RESET_INFO')
      }
    })
  },
  reset_info ({ commit, state }, params) {  // 修改个人资料
    commit('RESET_INFO')
  }
  // authorize_list ({ commit, state }, params) { // 获取授权列表
  //   authorizeApi.accpServiceList(params).then((json) => {
  //     commit('AUTHORIZE_LIST', {
  //       params: params,
  //       data: json.data
  //     })
  //   })
  // }
}
// mutations
const mutations = {
  PERSON_INFO (state, { data, params }) {
    state.person_info = data
  },
  RESET_INFO (state) {
    state.person_info = {}
  }
  // AUTHORIZE_LIST (state, data) {
  //   state.authorize_list = Object.assign({}, state.authorize_list, data)
  // }
}

export default {
  state,
  getters,
  actions,
  mutations
}
